import * as React from 'react';
import { Text, View, Image, Pressable, StyleSheet } from 'react-native';
import { userLogout } from '../store/user';
import { useDispatch, useStore } from 'react-redux';
import AsyncStorage from '@react-native-async-storage/async-storage';

function SettingsScreen({navigation}) {
  const dispatch = useDispatch();
  const store = useStore();

  async function logout(){
    dispatch(userLogout())
    !store.getState().user.token ? navigation.navigate('login') :  console.log('dengchucuowu')
  }

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <View style={settingstyle.userinfo}>
        <View style={settingstyle.avatar}>
          {/* <Image></Image> */}
        </View>
        <View>
          <Text>name</Text><Text>{}</Text>
        </View>
        <View>
          <Text>icon</Text>
        </View>
      </View>
      <View style={settingstyle.func}>
        <Text>List</Text>
      </View>

      <Pressable style={settingstyle.logout} onPress={logout}>
        <Text style={{}}>退出登录</Text>
      </Pressable>
    </View>
  );
}

const settingstyle = StyleSheet.create({
  userinfo:{
    borderRadius: 5,
  },
  avatar:{
    borderRadius: '50%',
  },
  func: {
    height: 300,
  },
  logout:{
    backgroundColor: 'rgba(163, 73, 164,0.7)',
    borderRadius: 5,
  }
})
export default SettingsScreen;